package listener

import (
	"common-api/message"
	"fmt"
)

var CurrentUserName string

type LoginListener struct {
}
type CommonListener struct {
}
type PrivateChatListener struct {
}

func (h *LoginListener) ProcessResponse(data any) {
	msg := data.(*message.LoginRespData)
	if msg.CommonResp.Code == message.SuccessCode {
		fmt.Printf("%s login success", msg.Username)
		CurrentUserName = msg.Username
		//heartbeat_job.CreateHeartBeatJob(msg.Username, h.Session)
	} else {
		fmt.Println("login failed", *msg)
	}
}

func (h *PrivateChatListener) ProcessResponse(data any) {
	msg := data.(*message.PrivateChatRespData)
	if msg.CommonResp.Code == message.SuccessCode {
		fmt.Println()
		fmt.Printf("%s 说: %s", msg.FromNickName, msg.ChatMessage)
	} else {
		fmt.Printf("%v\n", *msg)
	}
}

func (h *CommonListener) ProcessResponse(data any) {
	msg := data.(*message.CommonRespData)
	fmt.Printf("%v\n", *msg)
}
